package com.sxbbc.common.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sxbbc.common.core.dto.jz.ProGroupVo;
import com.sxbbc.common.core.dto.jz.SearchVo;
import com.sxbbc.common.core.entity.jz.ProGroupConfig;
import com.sxbbc.common.core.mapper.jz.ProGroupConfigMapper;
import com.sxbbc.common.core.service.IProGroupConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sxbbc.common.core.utils.BasePage;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 商品团购配置表 服务实现类
 * </p>
 *
 * @author leehao
 * @since 2019-05-30
 */
@Service
public class ProGroupConfigServiceImpl extends ServiceImpl<ProGroupConfigMapper, ProGroupConfig> implements IProGroupConfigService {

    @Override
    public List<ProGroupVo> queryTodayGroupProduct() {
        //获取今日开始与结束时间
        /*DateUtil dateUtil = DateUtil.getInstance();
        String beginTime = dateUtil.toDateTimeString(dateUtil.getStartTime(new Date()));
        String overTime = dateUtil.toDateTimeString(dateUtil.getEndTime(new Date()));*/
        //获取今日的团购商品列表
        List<ProGroupVo> list = super.baseMapper.queryTodayGroupProduct();
        return list;
    }

    @Override
    public IPage<ProGroupVo> queryGroupProductList(BasePage<ProGroupVo> page, SearchVo search) {
        return super.baseMapper.queryGroupProductList(page,search);
    }

    @Override
    public ProGroupConfig selectGroupProduct(String proCode) {
        QueryWrapper<ProGroupConfig> wrapper = new QueryWrapper<>();
        wrapper.eq("pro_code",proCode);
        return super.getOne(wrapper);
    }

    @Override
    public boolean updateWithNull(ProGroupConfig groupConfig) {
        int updateCount = baseMapper.updateWithNull(groupConfig);
        return updateCount > 0;
    }
}
